#coding=utf-8
import os, tsina
os.environ['DJANGO_SETTINGS_MODULE'] = 'coolie.settings'

message = 'hello, %s 想要流畅看Youtube,轻松上Facebook,Twitter，免费试用下Jayproxy吧 http://item.taobao.com/item.htm?id=5979785859'

from hellojayproxy.hjp.models import TsinaUser

t = tsina.TsinaRobot('twinsjp@sina.cn', 'jayproxy')
t.login()

cs = TsinaUser.objects.filter(is_ated=False).filter(client=u'新浪微博').order_by('-published_at')[:10]
at_names =' '.join( ['@%s'%c.nick_name.encode('u8') for c in cs] )
print message%at_names
t.publish( message%at_names)

for c in cs:
    c.is_ated = True
    c.save()
